# Python 2.6.4
# Project Euler, Problem 38
# Copyright 2010 Talha Zaman

def pan(n): return len(n)==9 and "123456789".strip(n)==""

P = set()
for i in range(1,100000):
    s = ""
    for n in range(1,10):
        s = s + str(i*n)
        if len(s)>9: break
        if pan(s): P.add(s)
print max(P)
